//
//  HYCollectionViewCellForT5.m
//  TTLestening
//
//  Created by dllo on 16/3/28.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "HYCollectionViewCellForT5.h"
#import "HYModelForRecommend.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface HYCollectionViewCellForT5 ()

@property (nonatomic, strong) UILabel *labelForReason;
@property (nonatomic, strong) UILabel *labelForName;
@property (nonatomic, strong) UILabel *labelForDesc;
@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UIButton *buttonForPlay;

@end

@implementation HYCollectionViewCellForT5

#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        [self createSubViews];
    }
    return self;
}

#pragma mark - createSubViews
- (void)createSubViews {
    
    self.labelForReason = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForReason];
    self.labelForReason.textColor = [UIColor grayColor];
    self.labelForReason.textAlignment = 1;
    self.labelForReason.font = [UIFont systemFontOfSize:14];
    
    self.labelForName = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForName];
    self.labelForName.textAlignment = 1;
    self.labelForName.font = [UIFont boldSystemFontOfSize:16];
    
    self.labelForDesc = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForDesc];
    self.labelForDesc.textAlignment = 1;
    self.labelForDesc.font = [UIFont boldSystemFontOfSize:14];
    
    self.imageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageView];
    
    self.buttonForPlay = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.buttonForPlay setImage:[UIImage imageNamed:@"iconfont-bofang-3"] forState:UIControlStateNormal];
    [self.contentView addSubview:self.buttonForPlay];
    [self.buttonForPlay addTarget:self action:@selector(addToPlay) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)addToPlay {
    
    NSLog(@"暂未实现5");
}

#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.imageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 2 - 20);
    
    self.labelForReason.frame = CGRectMake(0, self.contentView.frame.size.height / 2, self.contentView.frame.size.width, 20);
    
    self.labelForName.frame = CGRectMake(0, self.contentView.frame.size.height / 2 + 30, self.contentView.frame.size.width, 20);
    
    self.labelForDesc.frame = CGRectMake(0, self.contentView.frame.size.height / 2 + 60, self.contentView.frame.size.width, 20);
    
    self.buttonForPlay.frame = CGRectMake(0, 0, 50, 50);
    self.buttonForPlay.center = self.imageView.center;
    
    
}

#pragma mark - deliverModel

- (void)passMoldel:(HYModelForRecommend *)model {
    
    self.labelForName.text = model.name;
    self.labelForDesc.text = model.desc;
    self.labelForReason.text = model.reason;
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.picUrl] placeholderImage:[UIImage imageNamed:@"iconfont-jiazai"]];
}



@end
